<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>view/service/serviceLog/logManage</title>
    <!-- css代码 start -->
    <link href="../../../css/mui.min.css" rel="stylesheet"/>
    <link href="../../../css/global.css" rel="stylesheet"/>
    <link href="../../../css/style.css" rel="stylesheet"/>
    <link href="../../../css/checkbox.css" rel="stylesheet"/>
    <link rel="stylesheet" href="../../../css/mui.picker.css">
    <link rel="stylesheet" href="../../../css/mui.poppicker.css">
    <link href="../../../css/task.css" rel="stylesheet"/>
    <style>
        .d_int_tp {
            border: 0 !important;
            margin-top: 6px !important;
        }

        .details_con .btm .selectBtn {
            line-height: 28px;
            color: #ffffff;
            background: #ea1e1a;
        }

        .select-tzstate {
            width: 100%;
            border: 0;
            color: #a9a9a9;
            font-size: 16px;
            text-align: left;
            padding: 15px;
        }

        .mui-bar-nav {
            box-shadow: 0 1px 6px #ea1e1a;
        }
    </style>
    <!-- css代码 end -->
</head>
<body>
<!-- html代码 start -->
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 id="title" class="mui-title">工作日志管理</h1>
</header>
<div class="mui-content">
    <div class="details_con select_con">
        <div class="clum">
            <input type="text" class="d_int_tp" id="customerName" placeholder="请输入客户名称"/>
        </div>
        <div class="clum">
					<span class="txt" style="width: 100%;">
						<button id='serviceType' class="mui-btn mui-btn-block mui-btn-select select-tzstate" type='button'>请选择服务子类型</button>
					</span>
        </div>
        <div class="clum">
            <input type="text" class="d_int_tp" id="instSn" placeholder="请输入仪器序列号"/>
        </div>
        <div class="btm autoHeight">
            <p class="selectBtn" onclick="selectList()">查 询</p>
        </div>
    </div>

    <div class="details_con" style="margin: 30px 0 0 0;">
        <div class="item_box" id="itemBox"></div>
        <div style="height: 50px;"></div>
    </div>

</div>
<!-- html代码 end -->

<!-- js代码 start -->

<!-- 基础js start -->
<script src="../../../js/mui.min.js"></script>
<script src="../../../js/utils/h.js"></script>
<script src="../../../js/constant.js"></script>
<script src="../../../js/common.js"></script>
<script src="../../../js/utils/base64.js"></script>
<script src="../../../js/utils/md5.js"></script>
<script src="../../../js/utils/sortMap.js"></script>
<script src="../../../js/utils/http.js"></script>
<script src="../../../js/app.js"></script>
<!-- 基础js end -->
<script src="../../../js/mui.picker.js"></script>
<script src="../../../js/mui.poppicker.js"></script>

<script type="text/javascript" charset="utf-8">
    (function ($, doc) {
        $.init();

        $.plusReady(function () {
            selectList();

            h('#serviceType').tap(function(){
                app.hideSoftKeybord()
                var userPicker = new $.PopPicker();
                ajaxGetJson(BASE_URL + 'cc/dict/selectCCDict', {
                    tableName: 'snsubtype',
                    engineerId: app.getUser().enginnerId
                }, function (data) {
                    if (!data) {
                        app.toast("无下拉内容")
                        return
                    }
                    // 数组指定位置插入数据
                    // data.splice(0, 0, {"text": "请选择服务子类型", "value": ""});
                    userPicker.setData(data);
                    userPicker.show(function (items) {
                        h('#serviceType').html(items[0].text)
                        h('#serviceTypeValue').val(items[0].value)
                        userPicker.dispose()
                    });
                });
            })
        });
    }(mui, document));

    // 查询派单列表
    function selectList() {
        var customerName = h("#customerName").val();
        var serviceType = h("#serviceType").html();
        var instSn = h("#instSn").val();
        var fseId = app.getUser().enginnerId;

        if (!serviceType || serviceType == '请选择服务子类型') {
            serviceType = '';
        }
        app.showWaiting('加载中...')
        ajaxPost(BASE_URL + "cc/ServiceLog/selectUnboundList", {
            "customerName": customerName,
            "subServiceType": serviceType.indexOf("请选择") >= 0 ? "" : serviceType,
            "instSn": instSn,
            "fseId": fseId
        }, function (data) {
            app.closeWaiting()
            // console.log(JSON.stringify(data))
            if (data.code === 200) {
                // 无数据
                if (data.data.length == 0) {
                    h("#itemBox").html('<div class="nodata">—— 暂无数据 ——</div>');
                    return false;
                }
                // 显示列表
                var str = '';
                for (var i = 0; i < data.data.length; i++) {
                    var info = data.data[i];
                    str += '<div class="item" onclick="jumpToNext(\'' + info.serviceNo + '\',\'' + info.sendTime + '\')">';
                    str += '<div class="bar">';
                    str += '<span class="number"><img src="../../../images/icon_204.png" />' + info.serviceNo + '</span>';
                    var userTypeName = ''
                    if (info.user_isdpel == '1') {
                        userTypeName = 'DPEL/'
                    }
                    if (info.isVip != '') {
                        userTypeName += info.isVip
                    } else {
                        if (info.enginner_type != '') {
                            userTypeName += info.enginner_type
                        }
                    }
                    str += '<span class="vip">' + userTypeName + '</span>';
                    str += '</div>';
                    str += '<div class="type">';
                    str += '<p><img src="../../../images/icon_201.png" /><span class="lpl" style="width:auto;">客户名称：</span><span>' + info.customerName + '</span></p>';
                    str += '<p><img src="../../../images/icon_203.png" /><span class="lpl" style="width:auto;">服务子类型：</span><span>' + info.subServiceType + '</span></p>';
                    if (info.sendTime) {
                        // str += '<div class="text">' + info.sendTime + '<span class="l">提交时间：</span></div>';
                        str += '<p><img src="../../../images/icon_202.png"/><span class="lpl" style="width:auto;">提交时间：</span><span>' + info.sendTime +
                            '</span></p>';
                    } else {
                        str += '<p><img src="../../../images/icon_202.png"/><span class="lpl" style="width:auto;">提交时间：</span></p>';
                    }
                    str += '</div></div>';
                }
                h('#itemBox').html(str);
            } else {
				h("#itemBox").html('<div class="nodata">—— 暂无数据 ——</div>');
                app.toast(data.msg)
            }
        }, function (errorMsg) {
            app.closeWaiting()
			h("#itemBox").html('<div class="nodata">—— 暂无数据 ——</div>');
            app.toast("数据获取失败，请检查网络连接");
        });
    }

    // 跳转下一页
    function jumpToNext(serviceNo, sendTime) {
        app.jumpTo("/view/service/serviceLog/logList.html", "view/service/serviceLog/logList", {
            "serviceNo": serviceNo,
            "sendTime": sendTime,
        })
    }

    // 跳转详情
    function jumpToDetail(serviceNo) {
        app.jumpTo("/view/workArea/service/serveDetails.html", "view/workArea/service/serveDetails.html", {
            "serviceNo": serviceNo,
            "enginnerId": app.getUser().enginnerId
        })
    }
</script>
<!-- js代码 end -->
</body>
</html>
